<?php
/*
 * @Author: lokei
 * @Date: 2022-08-08 09:23:25
 * @LastEditors: lokei
 * @LastEditTime: 2022-11-26 09:12:47
 * @Description: 
 */

namespace App\Http\Controllers\Platform\Conf;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Pay\Conf\ConfModel;
use App\Models\Platform\Alias\AliasModel;

class InitController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    //

    public function get() {
        $alias = AliasModel::first();
        if(is_null($alias)) {
            $alias = new AliasModel();
            $alias->cart = '购物车';
            $alias->goods = '商品';
            $alias->save();
            $alias = AliasModel::first();
        }
        $pay_conf = ConfModel::select(['balance_on', 'card_on', 'aa_on'])->first();
        if(is_null($pay_conf)) {
            $pay_conf = new ConfModel();
            $pay_conf->balance_on = '0';
            $pay_conf->save();
            $pay_conf = ConfModel::select(['balance_on', 'card_on', 'aa_on'])->first();
        }
        $res = ResultTool::success();
        $res['data']['alias'] = $alias;
        $res['data']['pay_conf'] = $pay_conf;
        return $res;
    }

}
